package servlet;

import java.io.IOException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.CustomerServiceLocal;

public class CreateCustomer extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {	
		
			Context context=null;
			try {
				context = new InitialContext();
				 CustomerServiceLocal service =(CustomerServiceLocal)context.lookup("CustomerServiceImpl/local");
				  service.createCustomer();
				  request.setAttribute("msg", "success !");
			} catch (NamingException e) {
				e.printStackTrace();
				throw new ServletException(e);
			}		
		  request.getRequestDispatcher("/index.jsp").forward(request,response);
	}

}
